package org.openwork.util;
import javax.servlet.http.HttpServletRequest;

import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.Layout;

/**
 * 
 */

/**
 * @author samuelgmartinez
 *
 */
public class OpenWorkUtil {

	/**
	 * Workaround until this is implemented on PortalUtil
	 * 
	 * @param request
	 * @return true if request is executing on control panel group or false if not to
	 */
	public static boolean isControlPanel(HttpServletRequest request) {
		Boolean result = Boolean.FALSE;
		Layout layout = (Layout)request.getAttribute(WebKeys.LAYOUT);
		
		if(layout != null) { 
			try {
				result = layout.getGroup().isControlPanel();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} 
		
		return result;
	}
	
}
